window.log = function(){
	//stack('log');
	for (var i = 0; i<arguments.length;i++){
		if(window.console && window.console.log){
			//stack();
			window.console.log(arguments[i]);
		} else if(typeof Factory !== 'undefined' && Factory.flyer && typeof Factory.flyer.log === 'function'){
			//My.flyer.log(typeof arguments[i]==='string'?arguments[i] : My.printer.log(arguments[i]));
			Factory.flyer.log(arguments[i]);// TODO printer
		} else {
			window.alert(arguments[i])
		}
	}
};

window.stack = function(toLog){
	var callstack = [];
	try {
		i.dont.exist+=0;
	} catch(e) {
		if (e.stack) { //Firefox
			var lines = e.stack.split('\n');
			for (var i=0, len=lines.length; i<len; i++) {
				
				var match = lines[i].match(/http.*/);
				//match && (match[0].indexOf('ext-all-debug.js')== -1) && callstack.push(match[0]);
				match && callstack.push(match[0]);
			}
			callstack.shift();
		}
	}
	log(callstack,toLog);
};

window.onerror = function(){
	
	return false;// true konczy obsluge
}

isIn = function(){ // check if X is IN A,B,C (is equal to any)
	var a = arguments;
	var o = a[0];
	//log(arguments)
	for(i=1;i<a.length;i++){
		if (a[i] == o)return true;
	}
	return false;
}

is = function(what,returnIfIs){
	if(returnIfIs){
		return (what && what != '') ? returnIfIs : undefined;
	} else return (what && what != '');
}

notInAll = function(){ // 
	var a = arguments;
	var o = a[0];
	for(i=1;i<a.length;i++){
		if (a[i] != o)return true;
	}
	return false;
}

attributesNotEmpty = function (pars){ 
	for (x in pars){
		var t = eval('pars.'+x);
		if (!t || t == '')return false;
	}
	return true;
}


stripScripts = function (html) {
	if (!html)html='';
	return html.replace(/<script[^>]*?>[\s\S]*?<\/script>/gi, '');
}

